package cn.wolfcode.user.dao.impl;

import cn.wolfcode.user.dao.UserDAo;
import cn.wolfcode.user.entity.User;
import cn.wolfcode.util.MyBaitUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-10-28 20:36
 */
public class UserDAOImpl implements UserDAo {
    private SqlSession sqlSession= MyBaitUtils.getSSF();
    @Override
    public User checkLogin(String username, String password) {
        Map<String,String> map=new HashMap<>();
        map.put("username",username);
        map.put("password",password);
        //// TODO: 2024/10/28  
        return  sqlSession.selectOne("cn.wolfcode.user.mapper.UserMapper.checkLogin", map);
       
    }

    @Override
    public void editHeadImg(User user) {
        sqlSession.update("cn.wolfcode.user.mapper.UserMapper.editHeadImg",user);
       sqlSession.commit();
    }

    @Override
    public void insertInto(User user) {
        sqlSession.insert("cn.wolfcode.user.mapper.UserMapper.insert",user);
        sqlSession.commit();
    }

    @Override
    public List<String> selAllUserName() {
        List<String> objects = sqlSession.selectList("cn.wolfcode.user.mapper.UserMapper.selAllUserName");
        return objects;
    }

    @Override
    public void addNew(User user) {
        sqlSession.insert("cn.wolfcode.user.mapper.UserMapper.addNew",user);
        sqlSession.commit();
    }
}
